import Vue from 'vue'
import Router from 'vue-router'

Vue.use (Router)

/* Layout */
import Layout from '@/layout'

const commonRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    meta: {
      root: true
    },
    children: [
      {
        path: 'home',
        name: 'perfhomeormanceMenu',
        component: () => import('@/views/Home'),
        meta: {
          title: '首页', icon: 'dashboard', affix: true
        }
      },
      {
        path: 'performanceMenu',
        name: 'performanceMenu',
        component: () => import('@/views/performance'),
        meta: {
          title: '员工绩效'
        },
        alwaysShow: true,
        children: [
          {
            path: 'roster',
            name: 'roster.roster',
            component: () => import('@/views/roster/roster.vue'),
            meta: {
              title: '花名册'
            }
          },
          {
            path: 'performance',
            name: 'performance.performanceappraisal',
            component: () => import('@/views/performance/performanceappraisal.vue'),
            meta: {
              title: '绩效考核'
            }
          },
          {
            path: 'office',
            name: 'office.performanceoffice',
            component: () => import('@/views/office/performanceoffice.vue'),
            meta: {
              title: '绩效办公室'
            }
          },
          {
            path: 'personnelscore',
            name: 'office.personnelscore',
            component: () => import('@/views/office/personnelscore.vue'),
            meta: {
              title: '人员绩效分布图'
            }
          },
          {
            path: 'officeother',
            name: 'officeother.performanceofficeother',
            component: () => import('@/views/officeother/performanceofficeother.vue'),
            meta: {
              title: '绩效管理委员会'
            }
          },

          {
            path: 'appeal',
            name: 'appeal.appealform',
            component: () => import('@/views/appeal/appealform.vue'),
            meta: {
              title: '员工审批'
            }
          },
          {
            path: '/relatedSupport/jobGrowthPlan/growthDetails',
            name: 'relatedSupport.jobGrowthPlan.growthDetails',
            component: () => import('@/views/relatedSupport/jobGrowthPlan/growthDetails'),
            meta: {
              title: '岗位成长计划'
            },
            hidden: true
          },
        ]
      },
      {
        path: 'depperformanceMenu',
        name: 'depperformanceMenu',
        component: () => import('@/views/depperformance'),
        meta: {
          title: '部门绩效'
        },
        alwaysShow: true,
        children: [{
          path: 'depperformance',
          name: 'depperformance.depperformance',
          component: () => import('@/views/depperformance/depperformance.vue'),
          meta: {
            title: '绩效考核'
          }
        },
          {
            path: 'depperformanceoffice',
            name: 'depperformanceoffice.depperformanceoffice',
            component: () => import('@/views/depperformanceoffice/depperformanceoffice.vue'),
            meta: {
              title: '绩效办公室'
            }
          },
          {
            path: 'depperformanceofficeother',
            name: 'depperformanceofficeother.depperformanceofficeother',
            component: () => import('@/views/depperformanceofficeother/depperformanceofficeother.vue'),
            meta: {
              title: '绩效管理委员会'
            }
          },
          {
            path: 'depchart',
            name: 'depperformanceoffice.depchart',
            component: () => import('@/views/depperformanceoffice/depchart.vue'),
            meta: {
              title: '部门图表'
            }
          },

          {
            path: 'depindexchart',
            name: 'depperformanceoffice.depindexchart',
            component: () => import('@/views/depperformanceoffice/depindexchart.vue'),
            meta: {
              title: '部门指标库看板'
            }
          },

          //DeptExaminelRules
          {
            path: 'deptexaminelrules',
            name: 'deptexaminelrules.deptexaminelrules',
            component: () => import('@/views/deptexaminelrules/deptexaminelrules.vue'),
            meta: {
              title: '考核规则管理'
            }
          },
          {
            path: 'depappealform',
            name: 'depappealform.depappealform',
            component: () => import('@/views/depappealform/depappealform.vue'),
            meta: {
              title: '部门审批'
            }
          },
          {
            path: 'depperformanceinfo',
            name: 'depperformanceinfo.depperformanceinfo',
            component: () => import('@/views/depperformanceinfo/depperformanceinfo.vue'),
            meta: {
              title: '部门绩效查询'
            }
          },
          {
            path: 'deptInfo',
            name: 'deptInfo.deptInfo',
            component: () => import('@/views/deptInfo/deptInfo.vue'),
            meta: {
              title: '部门管理'
            }
          }
        ]
      },
      {
        path: 'personInfoManage',
        name: 'personInfoManage',
        component: () => import('@/views/personInfoManage'),
        // redirect: '/personInfoManage/performance/performanceList',
        meta: {
          title: '人员绩效管理'
        },
        alwaysShow: true,
        children: [
          {
            path: 'performance',
            name: 'personInfoManage.performanceList',
            component: () => import('@/views/personInfoManage/performanceList.vue'),
            meta: {
              title: '人员绩效管理'
            }
            // hidden: true
          }
        ]
      },
      {
        path: 'cokpitMenu',
        name: 'cokpitMenu',
        component: () => import('@/views/cokpitkanban'),
        meta: {
          title: '领导驾驶舱'
        },
        alwaysShow: true,
        children: [
          {
            path: 'cokpitkanban',
            name: 'cokpitkanban.cokpitkanban',
            component: () => import('@/views/cokpitkanban/cokpitkanban.vue'),
            meta: {
              title: '员工队伍情况'
            }
          },
          {
            path: 'talentPool',
            name: 'talentPool.talentPool',
            component: () => import('@/views/talentPool/talentPool.vue'),
            meta: {
              title: '人才库'
            }
          },
          {
            path: 'employeeGrow',
            name: 'employeeGrow.employeeGrow',
            component: () => import('@/views/employeeGrow'),
            meta: {
              title: '员工成长树'
            }
          },
          {
            path: 'jobGrowthPlanMenu',
            name: 'jobGrowthPlanMenu.jobGrowthPlanMenu',
            component: () => import('@/views/relatedSupport/jobGrowthPlan/growthList'),
            meta: {
              title: '岗位成长计划'
            }
          },
        ]
      },



      {
        path: '/module',
        name: 'module',
        component: () => import('@/views/module.vue'),
        meta: {title: ''}
      },
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true,
    meta: {
      type: 'common'
    }
  }
]

export const constantRoutes = [
  ...commonRoutes
]

export const asyncRoutes = []

const createRouter = () => new Router ({

  base: 'index.html/',
  mode: 'hash', // require service support
  scrollBehavior(to, from, savedPosition) {
  },
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
